<!--Generate by Kevin's CodeBuilder -->
<!--请注意！这里是页面片段，定义的标签ID，js变量不要与index.html列表页面重复-->
<!--如果是较复杂的页面，可以修改window的数据类型(dataType: iframe),然后将form.html改为完整的页面,实现iframe隔离，需要修改curdObj的访问方式为parent.curdObj-->
<div id="form_container" class="form_container">
		<!--利用隐藏的id标签区分是新增/编辑-->	
		<table class="form_table" style="margin-top:20px">
				<tr id="old_pwd_tr">
					<td class="label label30">[(${Lang.user_oldpwd})]</td>
					<td><input id="oldpwd" name="oldpwd" class="form_input form_input50" type="password"/></td>
				</tr>
				<tr >
					<td class="label label30">[(${Lang.user_newpwd})]</td>
					<td><input id="newpwd" name="newpwd" class="form_input form_input50" type="password"/></td>
				</tr>
		</table>
</div>
<script type="application/javascript" th:inline="javascript">
		var $form,
			validObj,
			needOldpwd,
			idValue;//用于区分新增,编辑
		$(function(){			
			$form = $("#form_container");
			idValue = '[(${userId})]';
			var validOpt = {
				newpwd: [{rule:'require'},{rule :{ minlength:6 }}]
            };
			var userId = '[(${loginUserId})]';
			if(userId === "0"){
				$("#old_pwd_tr").hide();
				needOldpwd = false;
			}else{
				validOpt["oldpwd"] = [{rule:'require'},{rule :{ minlength:6 }}];
				needOldpwd = true;
			}
			//创建校验
			validObj = new $B.Validate(validOpt, $form);
			
		});
		function resetPwdFn($win,btn){
			var oldpwd = $("#oldpwd").val();
			var newpwd = $("#newpwd").val();
			if((!needOldpwd && newpwd !== "") ||  (needOldpwd && oldpwd !== "" && newpwd !== "")){
				$B.request({
					data:{
						userId : idValue, 
						oldpwd : oldpwd , 
						newpwd : newpwd ,
						needOldpwd : needOldpwd
					},
					url:$B.getHttpHost(ctxPath)+"user/repasswd?cmd=update",
					ok:function(){
						$B.success('[(${Lang.common_saveSucess})]',2);
						$win.close();
					}
				},btn);
			}
		}
</script>
